package org.wheel.plugins.toolkit.sql.segment;

import cn.hutool.core.collection.CollUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.wheel.plugins.toolkit.sql.core.SqlSegment;

import java.util.List;

@Getter
@AllArgsConstructor
public class GroupBySegment implements SqlSegment {

    private final List<SqlSegment> columns;

    /* ========== 工厂 – 可变参 ========== */
    public static GroupBySegment of(SqlSegment... segments) {
        return new GroupBySegment(CollUtil.newArrayList(segments));
    }

    @Override
    public String getSql() {
        return CollUtil.join(columns, ", ", SqlSegment::getSql);
    }
}